@extends('admin.layout.index')

@section('content')

<div class="mws-panel grid_8">
  <div class="mws-panel-header">
    <span>
      <i class="icon-table"></i>{{ $title }}</span>
  </div>
  <div class="mws-panel-body no-padding">
    <div id="DataTables_Table_1_wrapper" class="dataTables_wrapper" role="grid">
      <div id="DataTables_Table_1_length" class="dataTables_length">
      <form action="" method="get">
        <label>显示
          <select size="1" name="count" aria-controls="DataTables_Table_1" value="">
            <option value="5" @if(!empty($request['count']) && $request['count'] == 5) selected @endif>5</option>
            <option value="8" @if(!empty($request['count']) && $request['count'] == 8) selected @endif>8</option>
            <option value="15" @if(!empty($request['count']) && $request['count'] == 15) selected @endif>15</option>
            <option value="20" @if(!empty($request['count']) && $request['count'] == 20) selected @endif>20</option></select>条</label>
      </div>
      <div class="dataTables_filter" id="DataTables_Table_1_filter">
        <label>关键字:
          <input type="text" aria-controls="DataTables_Table_1" name="search" value="{{$request['search'] or ''}}">
          <input type="submit" class="btn btn-success btn-xs" value="搜索">
        </label>
      </div>
      </form>
      <table class="mws-datatable-fn mws-table dataTable" id="DataTables_Table_1" aria-describedby="DataTables_Table_1_info">
        <thead>
          <tr role="row">
            <th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 141px;">ID</th>
            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 190px;">友情链接名称</th>
            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width: 174px;">友情链接地址</th>
            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 123px;">友情链接状态</th>
            <th  class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_1" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" style="width: 90px;">操作</th></tr>
        </thead>
        <tbody role="alert" aria-live="polite" aria-relevant="all">
        @foreach($data as $k=>$v)
          <tr class="odd">
            <td class="  sorting_1">{{ $v->lid }}</td>
            <td class=" ">{{ $v->lname }}</td>
            <td class=" ">{{ $v->llink }}</td>
            <td class=" ">{{ $v->lstatus == 0 ? '展示' : '隐藏' }}</td>
            <td class=" " style="width:150px;">
            	　<a href="javascript:void(0)" onclick="delLink({{$v->lid}})"><button class="btn btn-warning">删除</button></a>　
            	<a href="/admin/link/{{$v->lid}}/edit"><button class="btn btn-info">修改</button></a>
            </td>
          </tr>
         @endforeach
        </tbody>
      </table>
      <script>
      	function delLink($lid){
             
            layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                //            jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
                $.post('{{url('admin/link/')}}/'+$lid,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    //console.log(data);
//                    删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            });
        }

      </script>
      
      <!-- <div class="dataTables_paginate paging_full_numbers" id="DataTables_Table_1_paginate">
        <a tabindex="0" class="first paginate_button paginate_button_disabled" id="DataTables_Table_1_first">First</a>
        <a tabindex="0" class="previous paginate_button paginate_button_disabled" id="DataTables_Table_1_previous">Previous</a>
        <span>
          <a tabindex="0" class="paginate_active">1</a>
          <a tabindex="0" class="paginate_button">2</a>
          <a tabindex="0" class="paginate_button">3</a>
          <a tabindex="0" class="paginate_button">4</a>
          <a tabindex="0" class="paginate_button">5</a></span>
        <a tabindex="0" class="next paginate_button" id="DataTables_Table_1_next">Next</a>
        <a tabindex="0" class="last paginate_button" id="DataTables_Table_1_last">Last</a>
       </div> -->
       	<div id="page_page" class="">
			{!! $data->appends(['count'=>$count,'search'=>$search])->render() !!}
		</div>
    </div>
  </div>
</div>
@endsection